{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "数据集\n",
    "\n",
    "UCI 人类活动识别数据集是以智能手机采集的传感器数据为基础的活动识别，创建于2012年，实验团队来自意大利热那亚大学。在2012年的论文《Human Activity Recognition on Smartphones using a Multiclass Hardware-Friendly Support Vector Machine》中，采用机器学习算法建模，提供了该数据集分类性能的baseline。在2013年的论文《A Public Domain Dataset for Human Activity Recognition Using Smartphones》中，对数据集进行了全面描述。数据集可以从UCI机器学习存储库免费下载：👉传送门。\n",
    "\n",
    "http://archive.ics.uci.edu/ml/machine-learning-databases/00240/\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [],
   "source": [
    "'''\n",
    "-*- coding: utf-8 -*-\n",
    "@Time : 2021/8/7 20:55\n",
    "@Author : Small_Volcano\n",
    "@File : UCI_HAR_CNN.py\n",
    "'''\n",
    "import copy\n",
    "import time\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import torch.utils.data as Data\n",
    "from torch.optim import Adam\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import os"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [],
   "source": [
    "def load_file(filepath):\n",
    "    \"\"\"\n",
    "    加载文件\n",
    "    :param filepath:\n",
    "    :return:\n",
    "    \"\"\"\n",
    "    dataframe = pd.read_csv(filepath, header=None, delim_whitespace=True)\n",
    "    return dataframe.values"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [],
   "source": [
    "def load_dataset(data_rootdir, dirname, group):\n",
    "    '''\n",
    "    该函数实现将训练数据或测试数据文件列表堆叠为三维数组\n",
    "    '''\n",
    "    filename_list = []\n",
    "    filepath_list = []\n",
    "    X = []\n",
    "\n",
    "    # os.walk() 方法是一个简单易用的文件、目录遍历器，可以高效的处理文件、目录。\n",
    "    for rootdir, dirnames, filenames in os.walk(data_rootdir + dirname):\n",
    "        for filename in filenames:\n",
    "            filename_list.append(filename)\n",
    "            filepath_list.append(os.path.join(rootdir, filename))\n",
    "        #print(filename_list)\n",
    "        #print(filepath_list)\n",
    "\n",
    "    # 遍历根目录下的文件，并读取为DataFrame格式；\n",
    "    for filepath in filepath_list:\n",
    "        X.append(load_file(filepath))\n",
    "\n",
    "    X = np.dstack(X) # dstack沿第三个维度叠加，两个二维数组叠加后，前两个维度尺寸不变，第三个维度增加；\n",
    "    y = load_file(data_rootdir+'/y_'+group+'.txt')\n",
    "    print('{}_X.shape:{},{}_y.shape:{}\\n'.format(group,X.shape,group,y.shape))\n",
    "    return X, y"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train_X.shape:(7352, 128, 9),train_y.shape:(7352, 1)\n",
      "\n",
      "test_X.shape:(2947, 128, 9),test_y.shape:(2947, 1)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "train_rootdir = './UCI_HAR_Dataset/train/'\n",
    "test_rootdir = './UCI_HAR_Dataset/test/'\n",
    "data_dirname = '/Inertial Signals/'\n",
    "trainX, trainy = load_dataset(train_rootdir, data_dirname, 'train')\n",
    "testX, testy = load_dataset(test_rootdir, data_dirname, 'test')\n",
    "\n",
    "# data_x_raw.reshape(-1, 1, data_x_raw.shape[1], data_x_raw.shape[2])  # (N, C, H, W) (7352, 1, 128, 9)\n",
    "\n",
    "trainX = trainX.reshape(-1, 1, trainX.shape[1], trainX.shape[2])\n",
    "testX = testX.reshape(-1, 1, testX.shape[1], testX.shape[2])\n",
    "har_train_tensor = Data.TensorDataset(torch.from_numpy(trainX).to(torch.float32), torch.from_numpy(trainy) )\n",
    "har_test_tensor =  Data.TensorDataset(torch.from_numpy(testX).to(torch.float32), torch.from_numpy(testy))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'train_x_list' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "\u001B[1;32m~\\AppData\\Local\\Temp/ipykernel_5272/136696981.py\u001B[0m in \u001B[0;36m<module>\u001B[1;34m\u001B[0m\n\u001B[0;32m     16\u001B[0m         \u001B[1;32mreturn\u001B[0m \u001B[0mtorch_dataset\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m     17\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m---> 18\u001B[1;33m \u001B[0mdata_train\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mHAR\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mtrain_x_list\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mtrain_y_list\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;31m# 这一步是做什么？\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m     19\u001B[0m   \u001B[1;31m# 创造训练验证数据集\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m     20\u001B[0m \u001B[1;31m#print(har_train_tensor)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;31mNameError\u001B[0m: name 'train_x_list' is not defined"
     ]
    }
   ],
   "source": [
    "# class HAR(Data.Dataset):\n",
    "#     def __init__(self, filename_x, filename_y):\n",
    "#         self.filename_x = filename_x\n",
    "#         self.filename_y = filename_y\n",
    "#\n",
    "#     def HAR_data(self):\n",
    "#         \"\"\"更改x的维度,加载x和y\"\"\"\n",
    "#         data_x_raw = np.load(self.filename_x)\n",
    "#         #print(data_x_raw.shape)                                                        #为什么是1通道 128*9\n",
    "#         data_x = data_x_raw.reshape(-1, 1, data_x_raw.shape[1], data_x_raw.shape[2])  # (N, C, H, W) (7352, 1, 128, 9)\n",
    "#         # data_x = np.expand_dims(data_x_raw, 1)\n",
    "#         #print(data_x.shape)\n",
    "#         data_y = np.load(self.filename_y)\n",
    "#         print(\"datay{}\".format(data_y))\n",
    "#         torch_dataset = Data.TensorDataset(torch.from_numpy(data_x), torch.from_numpy(data_y))#造数据集\n",
    "#         return torch_dataset\n",
    "#\n",
    "# data_train = HAR(train_x_list, train_y_list)# 这一步是做什么？\n",
    "#   # 创造训练验证数据集\n",
    "# #print(har_train_tensor)\n",
    "# #测试集数据\n",
    "# data_test = HAR(test_x_list, test_y_list)\n",
    "# har_test_tensor = data_test.HAR_data()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [],
   "source": [
    "train_loader = Data.DataLoader(dataset=har_train_tensor,\n",
    "                               batch_size=128,\n",
    "                               shuffle=True,\n",
    "                               num_workers=0, )\n",
    "#设置一个测试集加载器\n",
    "test_loader = Data.DataLoader(dataset=har_test_tensor,\n",
    "                               batch_size=1,\n",
    "                               shuffle=True,\n",
    "                               num_workers=0, )"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "outputs": [],
   "source": [
    "#搭建卷积神经网络\n",
    "class Net(nn.Module):\n",
    "    def __init__(self):\n",
    "        super(Net, self).__init__()\n",
    "        #定义第一个卷积层\n",
    "        self.conv1 = nn.Sequential(\n",
    "            nn.Conv2d(in_channels=1,\n",
    "                      out_channels=12,          #输出高度12\n",
    "                      kernel_size=3,            #卷积核尺寸3*3\n",
    "                      stride=1,\n",
    "                      padding=1),               #(1*128*9)-->(12*128*9)\n",
    "            nn.ReLU(),\n",
    "            nn.MaxPool2d(kernel_size=2,stride=2) #(12*128*9)-->(12*64*4)\n",
    "        )\n",
    "        #定义第二个卷积层\n",
    "        self.conv2 = nn.Sequential(\n",
    "            nn.Conv2d(in_channels=12,\n",
    "                      out_channels=32,\n",
    "                      kernel_size=3,\n",
    "                      stride=1,\n",
    "                      padding=1),               #(12*64*4)-->(32*64*4)\n",
    "            nn.ReLU(),\n",
    "            nn.MaxPool2d(kernel_size=2,stride=2) #池化后：(32*32*2)\n",
    "        )\n",
    "        self.conv3 = nn.Sequential(\n",
    "            nn.Conv2d(in_channels=32,\n",
    "                      out_channels=64,\n",
    "                      kernel_size=3,\n",
    "                      stride=1,\n",
    "                      padding=1),                #(32*32*2)-->(64*32*2)\n",
    "            nn.ReLU()\n",
    "        )\n",
    "        #定义全连接层\n",
    "        self.classifier = nn.Sequential(\n",
    "            nn.Linear(64*32*2,128),              #长方体变平面\n",
    "            nn.ReLU(),\n",
    "            nn.Dropout(p = 0.5),\n",
    "            nn.Linear(128,6)\n",
    "        )\n",
    "\n",
    "    #定义网络的前向传播路径\n",
    "    def forward(self,x):\n",
    "        x = self.conv1(x)\n",
    "        print('conv1',x.shape)\n",
    "        x = self.conv2(x)\n",
    "        print('conv2',x.shape)\n",
    "        x = self.conv3(x)\n",
    "        print('conv3',x.shape)\n",
    "        x = x.view(x.shape[0],-1) #展平多维的卷积图层\n",
    "        output = self.classifier(x)\n",
    "        print('output',output.shape)\n",
    "        return output"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "outputs": [],
   "source": [
    "#定义网络的训练过程函数\n",
    "def train_model(model,traindataloader,train_rate,criterion,optimizer,num_epochs=25):\n",
    "    #train_rate：训练集中训练数量的百分比\n",
    "    #计算训练使用的batch数量\n",
    "    batch_num = len(traindataloader)\n",
    "    train_batch_num = round(batch_num * train_rate) #前train_rate（80%）的batch进行训练\n",
    "    #复制最好模型的参数\n",
    "    best_model_wts = copy.deepcopy(model.state_dict())\n",
    "    best_acc = 0.0\n",
    "    train_loss_all = []\n",
    "    train_acc_all =    []\n",
    "    val_loss_all = []\n",
    "    val_acc_all = []\n",
    "    since = time.time()\n",
    "    for epoch in range(num_epochs):\n",
    "        print('Epoch {}/{}'.format(epoch,num_epochs-1)) #格式化字符串\n",
    "        print('-' * 10)\n",
    "        #每个epoch有两个训练阶段\n",
    "        train_loss = 0.0\n",
    "        train_corrects = 0\n",
    "        train_num = 0\n",
    "        val_loss = 0.0\n",
    "        val_corrects = 0\n",
    "        val_num = 0\n",
    "        for step,(b_x,b_y) in enumerate(traindataloader,1): #取标签和样本\n",
    "            b_y = b_y.long()\n",
    "            if step < train_batch_num:                      #前train_rate（80%）的batch进行训练\n",
    "                model.train()                               #设置模型为训练模式，对Droopou有用\n",
    "                output = model(b_x)\n",
    "               # print(b_x)#取得模型预测结果\n",
    "                pre_lab = torch.argmax(output,1)            #横向获得最大值位置\n",
    "                b_y = b_y.squeeze(1)-1            #修改BUG\n",
    "                print(b_y.shape, b_y)\n",
    "                loss = criterion(output,b_y)                #每个样本的loss\n",
    "                optimizer.zero_grad()\n",
    "                loss.backward()\n",
    "                optimizer.step()                            #修改权值\n",
    "                train_loss += loss.item() * b_x.size(0)\n",
    "                #print(pre_lab)\n",
    "                #print(b_y.data)\n",
    "                train_corrects += torch.sum(pre_lab == b_y.data) #训练正确个数\n",
    "                train_num += b_x.size(0)\n",
    "            else:\n",
    "                model.eval()                                    #设置模型为验证模式\n",
    "                output = model(b_x)\n",
    "                pre_lab = torch.argmax(output,1)\n",
    "                loss = criterion(output,b_y)\n",
    "                val_loss += loss.item() * b_x.size(0)\n",
    "                val_corrects += torch.sum(pre_lab == b_y.data)\n",
    "                val_num += b_x.size(0)\n",
    "        #计算训练集和验证集上的损失和精度\n",
    "        train_loss_all.append(train_loss / train_num)           #一个epoch上的loss\n",
    "        train_acc_all.append(train_corrects.double().item() / train_num)\n",
    "        val_loss_all.append(val_loss / val_num)\n",
    "        val_acc_all.append(val_corrects.double().item() / val_num)\n",
    "\n",
    "        print('{} Train Loss: {:.4f} Train Acc: {:.4f}'.format(epoch,train_loss_all[-1],train_acc_all[-1])) #此处-1没搞明白\n",
    "        print('{} Val Loss: {:.4f} Val Acc: {:.4f}'.format(epoch,val_loss_all[-1],val_acc_all[-1]))\n",
    "        #拷贝模型最高精度下的参数\n",
    "        if val_acc_all[-1] > best_acc:\n",
    "            best_acc = val_acc_all[-1]\n",
    "            best_model_wts = copy.deepcopy(model.state_dict())\n",
    "            torch.save(model.state_dict(),\"UCI_HAR_model\")\n",
    "            torch.save(optimizer.state_dict(),\"UCI_HAR_optimizer\")\n",
    "        time_use = time.time() - since\n",
    "        print(\"Train and val complete in {:.0f}m {:.0f}s\".format(time_use // 60,time_use % 60)) #训练用时\n",
    "    #使用最好模型的参数\n",
    "    model.load_state_dict(best_model_wts)\n",
    "    #组成数据表格train_process打印\n",
    "    train_process = pd.DataFrame(data={\"epoch\":range(num_epochs),\n",
    "                                       \"train_loss_all\":train_loss_all,\n",
    "                                       \"val_loss_all\":val_loss_all,\n",
    "                                       \"train_acc_all\":train_acc_all,\n",
    "                                       \"val_acc_all\":val_acc_all})\n",
    "    return model,train_process"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Net(\n",
      "  (conv1): Sequential(\n",
      "    (0): Conv2d(1, 12, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
      "    (1): ReLU()\n",
      "    (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "  )\n",
      "  (conv2): Sequential(\n",
      "    (0): Conv2d(12, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
      "    (1): ReLU()\n",
      "    (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "  )\n",
      "  (conv3): Sequential(\n",
      "    (0): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
      "    (1): ReLU()\n",
      "  )\n",
      "  (classifier): Sequential(\n",
      "    (0): Linear(in_features=4096, out_features=128, bias=True)\n",
      "    (1): ReLU()\n",
      "    (2): Dropout(p=0.5, inplace=False)\n",
      "    (3): Linear(in_features=128, out_features=6, bias=True)\n",
      "  )\n",
      ")\n",
      "Epoch 0/24\n",
      "----------\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 0, 3, 5, 2, 4, 5, 4, 5, 0, 3, 0, 1, 1, 4, 2, 3, 1, 4, 1, 0, 0, 3, 4,\n",
      "        4, 4, 0, 3, 2, 4, 4, 5, 5, 2, 4, 4, 5, 0, 2, 1, 1, 3, 5, 4, 4, 1, 3, 1,\n",
      "        0, 2, 4, 5, 3, 5, 4, 1, 3, 1, 5, 2, 5, 1, 3, 1, 1, 3, 3, 3, 1, 2, 1, 3,\n",
      "        3, 0, 4, 0, 5, 3, 1, 0, 1, 5, 5, 4, 4, 0, 4, 5, 3, 1, 4, 1, 4, 1, 4, 5,\n",
      "        0, 2, 0, 4, 5, 3, 4, 5, 5, 3, 5, 0, 2, 1, 2, 2, 4, 5, 4, 3, 2, 4, 2, 2,\n",
      "        3, 1, 4, 3, 0, 3, 0, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 5, 1, 5, 2, 1, 2, 5, 1, 3, 4, 2, 0, 4, 1, 0, 4, 3, 2, 2, 2, 5, 0, 2,\n",
      "        5, 0, 3, 4, 0, 1, 0, 1, 5, 3, 0, 1, 5, 5, 2, 1, 1, 5, 3, 5, 0, 3, 1, 5,\n",
      "        1, 5, 4, 1, 1, 4, 3, 0, 1, 0, 5, 2, 4, 4, 2, 3, 3, 0, 1, 2, 0, 5, 1, 5,\n",
      "        4, 3, 4, 5, 0, 1, 4, 0, 2, 4, 3, 4, 1, 5, 3, 0, 4, 0, 3, 0, 5, 3, 3, 5,\n",
      "        1, 3, 4, 1, 3, 5, 0, 5, 0, 3, 4, 0, 5, 2, 3, 3, 5, 2, 4, 0, 5, 5, 3, 5,\n",
      "        4, 2, 2, 2, 4, 0, 1, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 4, 4, 3, 3, 4, 3, 1, 5, 0, 4, 4, 5, 3, 4, 5, 4, 4, 5, 4, 0, 3, 5, 1,\n",
      "        3, 0, 5, 1, 4, 4, 0, 4, 3, 2, 5, 3, 2, 5, 3, 4, 1, 3, 0, 3, 5, 4, 3, 3,\n",
      "        1, 5, 3, 4, 2, 4, 0, 5, 4, 4, 4, 3, 0, 1, 3, 1, 2, 0, 4, 0, 5, 0, 0, 2,\n",
      "        0, 0, 4, 5, 3, 5, 4, 4, 0, 0, 5, 5, 5, 2, 0, 0, 3, 1, 4, 1, 3, 0, 3, 3,\n",
      "        0, 5, 4, 5, 4, 4, 4, 3, 0, 5, 4, 3, 4, 1, 5, 5, 3, 0, 4, 0, 4, 2, 3, 2,\n",
      "        0, 2, 0, 0, 2, 5, 0, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 1, 5, 1, 3, 1, 2, 5, 5, 1, 5, 5, 3, 3, 0, 3, 4, 0, 5, 0, 3, 1, 0, 0,\n",
      "        3, 1, 3, 0, 4, 2, 5, 0, 5, 4, 4, 4, 0, 1, 4, 2, 4, 2, 2, 1, 5, 2, 4, 1,\n",
      "        3, 2, 0, 5, 5, 4, 3, 5, 5, 5, 5, 0, 4, 5, 0, 2, 0, 3, 5, 5, 3, 5, 5, 5,\n",
      "        5, 1, 5, 0, 5, 0, 4, 4, 0, 2, 0, 5, 0, 4, 1, 1, 2, 1, 5, 4, 1, 3, 5, 3,\n",
      "        0, 2, 3, 3, 4, 0, 3, 5, 3, 4, 0, 5, 1, 2, 3, 4, 4, 2, 2, 0, 4, 4, 4, 0,\n",
      "        4, 3, 2, 3, 0, 5, 3, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 3, 4, 3, 4, 1, 3, 5, 0, 2, 5, 0, 2, 1, 5, 4, 4, 1, 4, 0, 1, 2, 5, 1,\n",
      "        4, 3, 4, 4, 4, 0, 1, 2, 4, 5, 4, 4, 5, 5, 5, 5, 3, 0, 1, 1, 0, 5, 1, 3,\n",
      "        0, 1, 5, 5, 5, 4, 2, 5, 3, 1, 0, 4, 5, 1, 0, 5, 5, 4, 5, 2, 5, 5, 1, 4,\n",
      "        3, 3, 0, 5, 0, 2, 4, 1, 2, 0, 1, 2, 3, 4, 3, 2, 0, 0, 3, 4, 3, 3, 3, 5,\n",
      "        5, 3, 2, 3, 4, 4, 3, 3, 0, 1, 2, 5, 3, 1, 3, 0, 0, 3, 3, 3, 5, 0, 1, 4,\n",
      "        0, 1, 4, 5, 1, 3, 5, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 4, 2, 4, 5, 1, 4, 2, 0, 2, 1, 2, 5, 0, 4, 5, 3, 3, 4, 1, 1, 3, 2, 2,\n",
      "        2, 5, 2, 0, 0, 5, 3, 4, 5, 3, 5, 1, 4, 4, 5, 2, 2, 3, 4, 5, 5, 5, 5, 3,\n",
      "        5, 0, 5, 0, 2, 0, 3, 4, 4, 1, 3, 5, 1, 3, 2, 5, 0, 4, 2, 4, 3, 0, 5, 2,\n",
      "        2, 0, 4, 0, 0, 5, 5, 1, 1, 5, 4, 3, 4, 0, 4, 1, 2, 3, 1, 2, 2, 0, 0, 3,\n",
      "        2, 0, 2, 2, 5, 5, 3, 1, 4, 4, 3, 3, 4, 0, 2, 4, 3, 4, 1, 4, 1, 3, 3, 2,\n",
      "        4, 0, 1, 3, 2, 5, 0, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 0, 5, 3, 4, 2, 0, 4, 2, 3, 1, 0, 4, 4, 0, 5, 5, 3, 1, 5, 1, 5, 5, 4,\n",
      "        4, 0, 4, 5, 4, 5, 4, 4, 2, 2, 0, 0, 0, 0, 1, 5, 1, 1, 0, 2, 1, 3, 1, 4,\n",
      "        1, 5, 5, 5, 4, 4, 0, 0, 5, 0, 2, 4, 1, 1, 3, 0, 4, 4, 3, 4, 5, 3, 5, 4,\n",
      "        0, 4, 2, 4, 3, 3, 3, 0, 5, 4, 1, 4, 1, 2, 5, 4, 1, 1, 2, 2, 0, 1, 1, 2,\n",
      "        5, 1, 5, 0, 3, 3, 0, 2, 5, 4, 2, 0, 1, 1, 0, 3, 1, 1, 0, 3, 3, 0, 1, 2,\n",
      "        5, 4, 5, 4, 1, 1, 2, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 3, 3, 4, 5, 0, 2, 4, 0, 0, 5, 5, 3, 1, 5, 0, 5, 4, 2, 0, 5, 1, 4, 2,\n",
      "        1, 2, 2, 3, 5, 4, 0, 5, 4, 4, 5, 4, 4, 2, 3, 5, 2, 0, 2, 0, 2, 1, 2, 5,\n",
      "        4, 3, 5, 3, 4, 4, 1, 0, 3, 2, 4, 1, 2, 5, 5, 1, 0, 5, 4, 3, 1, 1, 1, 4,\n",
      "        4, 4, 4, 1, 5, 2, 4, 3, 2, 4, 1, 0, 2, 5, 0, 2, 1, 2, 3, 2, 4, 5, 4, 3,\n",
      "        3, 3, 3, 3, 0, 5, 1, 4, 1, 3, 0, 3, 5, 5, 2, 4, 2, 3, 4, 5, 0, 2, 3, 0,\n",
      "        2, 5, 3, 1, 1, 1, 3, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([1, 5, 1, 2, 5, 0, 1, 0, 0, 5, 3, 5, 2, 5, 2, 5, 5, 2, 5, 5, 0, 4, 1, 1,\n",
      "        3, 4, 0, 0, 0, 2, 4, 5, 3, 0, 1, 2, 1, 2, 4, 1, 4, 2, 1, 5, 2, 1, 4, 5,\n",
      "        4, 4, 1, 1, 4, 1, 2, 5, 0, 0, 0, 3, 1, 2, 3, 2, 4, 1, 2, 5, 1, 4, 0, 5,\n",
      "        3, 4, 3, 4, 5, 5, 5, 5, 0, 3, 5, 2, 3, 4, 5, 1, 1, 1, 4, 4, 5, 3, 1, 3,\n",
      "        0, 1, 0, 3, 1, 0, 5, 0, 0, 2, 3, 0, 1, 0, 4, 2, 3, 0, 1, 5, 0, 3, 0, 5,\n",
      "        0, 3, 4, 4, 3, 2, 5, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 3, 4, 5, 5, 1, 1, 5, 4, 4, 2, 4, 5, 1, 3, 4, 0, 1, 5, 2, 4, 3, 3, 1,\n",
      "        5, 2, 2, 1, 2, 2, 1, 5, 5, 2, 3, 0, 5, 4, 5, 0, 0, 0, 1, 1, 1, 5, 1, 5,\n",
      "        4, 5, 3, 3, 3, 5, 2, 2, 3, 2, 1, 5, 4, 3, 0, 3, 5, 1, 1, 5, 0, 0, 5, 5,\n",
      "        1, 2, 0, 1, 4, 4, 3, 2, 5, 4, 2, 5, 3, 5, 3, 3, 5, 4, 2, 2, 1, 2, 2, 5,\n",
      "        5, 5, 0, 3, 5, 0, 3, 2, 4, 1, 4, 2, 4, 2, 4, 4, 2, 3, 1, 1, 3, 2, 2, 1,\n",
      "        5, 3, 2, 4, 2, 1, 3, 0])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 0, 4, 1, 2, 3, 5, 5, 0, 5, 2, 2, 2, 5, 3, 3, 5, 3, 5, 0, 0, 2, 3, 3,\n",
      "        3, 5, 3, 1, 5, 2, 1, 4, 2, 3, 1, 0, 2, 1, 1, 3, 4, 3, 1, 3, 1, 5, 3, 5,\n",
      "        1, 3, 5, 2, 4, 2, 2, 2, 0, 5, 0, 5, 0, 0, 1, 5, 2, 3, 4, 2, 4, 0, 4, 4,\n",
      "        1, 3, 1, 5, 5, 4, 1, 1, 5, 5, 4, 2, 3, 1, 0, 3, 1, 0, 5, 3, 5, 5, 5, 5,\n",
      "        3, 5, 5, 4, 5, 5, 4, 1, 0, 4, 4, 5, 3, 4, 5, 5, 4, 4, 4, 2, 0, 5, 5, 2,\n",
      "        1, 0, 0, 0, 0, 2, 1, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 5, 4, 0, 0, 4, 1, 2, 1, 4, 5, 0, 2, 4, 3, 4, 0, 1, 5, 1, 3, 1, 5, 3,\n",
      "        0, 5, 4, 0, 3, 5, 3, 4, 4, 1, 5, 1, 4, 3, 5, 4, 1, 1, 1, 4, 4, 4, 0, 4,\n",
      "        4, 2, 2, 5, 5, 4, 3, 5, 0, 0, 1, 3, 2, 1, 0, 4, 5, 5, 5, 3, 2, 3, 3, 3,\n",
      "        4, 2, 4, 4, 4, 0, 3, 1, 0, 0, 5, 5, 2, 2, 2, 1, 5, 2, 1, 1, 5, 0, 2, 5,\n",
      "        2, 4, 0, 0, 3, 1, 4, 1, 0, 5, 4, 4, 4, 1, 1, 5, 3, 4, 1, 2, 3, 4, 1, 0,\n",
      "        0, 4, 0, 1, 4, 2, 5, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([1, 5, 4, 1, 1, 5, 0, 4, 3, 3, 0, 4, 0, 5, 5, 5, 1, 3, 4, 5, 3, 5, 3, 5,\n",
      "        5, 0, 4, 3, 4, 3, 3, 3, 0, 1, 0, 4, 0, 1, 2, 2, 0, 4, 5, 5, 0, 5, 1, 3,\n",
      "        5, 3, 1, 1, 2, 1, 2, 0, 5, 5, 2, 0, 1, 1, 3, 4, 1, 3, 4, 3, 4, 0, 3, 3,\n",
      "        3, 0, 2, 2, 0, 4, 1, 3, 4, 3, 4, 4, 4, 0, 2, 0, 1, 3, 0, 0, 5, 0, 3, 5,\n",
      "        3, 3, 2, 0, 3, 5, 4, 0, 5, 0, 0, 0, 5, 0, 1, 3, 3, 0, 4, 3, 3, 5, 3, 3,\n",
      "        0, 5, 2, 0, 5, 3, 2, 0])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([1, 1, 2, 4, 1, 0, 2, 0, 3, 0, 1, 1, 3, 3, 0, 5, 1, 0, 5, 4, 2, 4, 1, 1,\n",
      "        0, 1, 4, 3, 4, 5, 4, 5, 1, 4, 0, 5, 4, 1, 5, 1, 2, 0, 1, 5, 4, 3, 0, 5,\n",
      "        5, 5, 4, 5, 5, 3, 1, 0, 3, 5, 2, 0, 2, 5, 2, 1, 5, 3, 1, 3, 5, 5, 4, 5,\n",
      "        0, 5, 3, 3, 0, 3, 0, 5, 5, 4, 1, 0, 3, 2, 1, 0, 4, 1, 3, 5, 1, 2, 5, 0,\n",
      "        1, 4, 4, 4, 4, 2, 2, 2, 5, 2, 3, 2, 0, 4, 0, 4, 3, 5, 5, 3, 3, 4, 4, 5,\n",
      "        5, 3, 1, 2, 4, 0, 4, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 4, 2, 1, 2, 1, 2, 0, 4, 3, 3, 5, 4, 2, 4, 1, 4, 5, 5, 4, 0, 5, 5, 3,\n",
      "        0, 5, 2, 5, 0, 2, 4, 1, 4, 0, 0, 0, 1, 1, 5, 1, 4, 4, 3, 5, 1, 3, 5, 2,\n",
      "        3, 3, 2, 1, 4, 0, 3, 3, 3, 0, 4, 4, 4, 4, 2, 1, 2, 3, 5, 5, 2, 2, 2, 5,\n",
      "        3, 3, 4, 4, 5, 5, 5, 4, 4, 3, 5, 2, 5, 0, 3, 4, 2, 3, 1, 0, 4, 2, 5, 3,\n",
      "        4, 2, 0, 1, 4, 5, 0, 2, 2, 5, 0, 3, 3, 5, 3, 1, 3, 1, 3, 4, 1, 1, 1, 3,\n",
      "        5, 5, 5, 4, 2, 5, 0, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([1, 3, 5, 1, 0, 2, 5, 0, 5, 0, 3, 4, 2, 4, 3, 2, 0, 0, 5, 1, 0, 4, 0, 4,\n",
      "        3, 1, 4, 4, 4, 0, 3, 0, 0, 4, 0, 1, 0, 2, 5, 4, 4, 0, 3, 0, 3, 3, 1, 5,\n",
      "        3, 0, 4, 3, 4, 4, 1, 5, 4, 5, 3, 4, 5, 5, 4, 3, 0, 5, 4, 0, 2, 4, 0, 5,\n",
      "        5, 5, 0, 5, 1, 1, 4, 4, 4, 4, 5, 3, 5, 0, 3, 1, 5, 4, 3, 4, 4, 2, 5, 2,\n",
      "        4, 4, 0, 3, 5, 3, 3, 4, 5, 5, 4, 5, 2, 4, 4, 1, 1, 3, 4, 3, 0, 2, 2, 4,\n",
      "        5, 1, 4, 4, 4, 5, 0, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 1, 3, 0, 4, 4, 4, 0, 5, 3, 2, 1, 5, 0, 3, 3, 0, 5, 0, 2, 3, 2, 5, 0,\n",
      "        0, 5, 4, 5, 0, 0, 3, 0, 3, 4, 0, 0, 1, 3, 5, 2, 2, 2, 4, 5, 0, 1, 1, 0,\n",
      "        5, 0, 0, 5, 3, 5, 4, 5, 1, 4, 0, 5, 5, 3, 4, 0, 5, 2, 1, 5, 1, 4, 3, 4,\n",
      "        0, 3, 1, 1, 5, 0, 5, 3, 4, 5, 2, 4, 3, 1, 5, 0, 5, 2, 2, 3, 4, 1, 0, 4,\n",
      "        5, 3, 0, 4, 3, 2, 0, 0, 0, 5, 2, 4, 1, 5, 2, 0, 0, 4, 2, 0, 3, 4, 1, 4,\n",
      "        1, 5, 4, 0, 1, 3, 0, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 5, 5, 0, 4, 3, 1, 3, 0, 1, 1, 5, 4, 5, 4, 0, 2, 3, 0, 4, 0, 5, 4, 4,\n",
      "        3, 3, 3, 3, 2, 0, 4, 0, 5, 4, 5, 2, 5, 1, 4, 0, 5, 4, 2, 3, 5, 1, 4, 2,\n",
      "        0, 0, 4, 3, 3, 3, 1, 4, 5, 2, 1, 2, 5, 2, 5, 2, 1, 5, 0, 0, 4, 5, 4, 4,\n",
      "        2, 2, 1, 4, 5, 3, 3, 1, 4, 2, 5, 0, 3, 2, 5, 2, 2, 2, 3, 4, 5, 0, 5, 1,\n",
      "        4, 2, 4, 3, 3, 5, 5, 4, 5, 5, 4, 2, 1, 1, 1, 2, 2, 5, 3, 1, 5, 0, 5, 1,\n",
      "        4, 2, 0, 2, 3, 4, 0, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([1, 5, 3, 2, 4, 4, 5, 0, 0, 3, 5, 3, 2, 2, 2, 0, 5, 3, 0, 4, 4, 4, 0, 4,\n",
      "        3, 5, 4, 5, 0, 4, 4, 0, 0, 3, 1, 1, 1, 2, 0, 0, 5, 5, 1, 2, 4, 2, 5, 0,\n",
      "        0, 1, 5, 3, 5, 4, 5, 5, 5, 5, 5, 4, 4, 1, 5, 1, 5, 1, 1, 5, 4, 3, 1, 2,\n",
      "        0, 4, 0, 1, 0, 0, 0, 4, 3, 3, 2, 2, 4, 4, 2, 2, 2, 2, 4, 0, 5, 4, 3, 2,\n",
      "        1, 0, 3, 5, 0, 4, 3, 1, 3, 1, 0, 3, 5, 3, 5, 1, 3, 4, 5, 0, 1, 1, 5, 1,\n",
      "        2, 3, 4, 4, 4, 0, 4, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 2, 1, 1, 1, 0, 3, 2, 5, 0, 1, 4, 5, 2, 2, 1, 1, 5, 3, 5, 3, 4, 1, 4,\n",
      "        1, 0, 5, 2, 2, 4, 3, 3, 0, 1, 1, 1, 4, 4, 0, 5, 3, 5, 1, 4, 1, 2, 0, 2,\n",
      "        4, 3, 4, 5, 4, 5, 1, 2, 1, 3, 4, 3, 4, 5, 5, 5, 4, 3, 0, 2, 1, 2, 2, 1,\n",
      "        3, 3, 5, 3, 2, 3, 4, 0, 3, 5, 5, 4, 5, 4, 3, 3, 0, 5, 0, 3, 1, 5, 3, 0,\n",
      "        2, 1, 2, 0, 4, 5, 1, 0, 5, 5, 5, 3, 0, 5, 3, 0, 3, 5, 3, 0, 5, 5, 0, 2,\n",
      "        3, 1, 5, 5, 2, 3, 5, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 5, 5, 5, 2, 0, 4, 0, 4, 2, 3, 5, 0, 3, 3, 4, 1, 1, 2, 1, 0, 5, 2, 3,\n",
      "        3, 4, 2, 4, 2, 5, 5, 1, 0, 1, 5, 3, 4, 0, 5, 5, 4, 4, 5, 2, 5, 2, 4, 2,\n",
      "        4, 0, 0, 0, 5, 4, 1, 1, 4, 3, 5, 4, 4, 5, 0, 2, 0, 4, 4, 3, 3, 3, 5, 2,\n",
      "        0, 2, 1, 3, 1, 5, 3, 4, 1, 3, 3, 5, 5, 5, 0, 0, 2, 4, 2, 1, 1, 3, 4, 4,\n",
      "        2, 3, 1, 5, 5, 4, 1, 3, 1, 0, 3, 0, 4, 2, 4, 2, 3, 2, 3, 0, 3, 1, 2, 5,\n",
      "        5, 4, 3, 3, 4, 3, 2, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 0, 4, 4, 3, 5, 4, 0, 3, 5, 4, 3, 1, 3, 0, 3, 1, 2, 4, 2, 2, 1, 0, 2,\n",
      "        1, 4, 0, 5, 3, 5, 5, 3, 4, 3, 4, 5, 4, 0, 3, 0, 5, 1, 4, 2, 3, 4, 4, 3,\n",
      "        1, 2, 1, 5, 1, 3, 1, 5, 4, 3, 4, 3, 4, 0, 1, 3, 3, 1, 4, 4, 3, 1, 2, 1,\n",
      "        5, 0, 2, 5, 0, 0, 1, 4, 1, 3, 3, 4, 2, 4, 5, 3, 4, 5, 3, 3, 4, 4, 5, 5,\n",
      "        1, 2, 5, 4, 5, 3, 5, 1, 3, 0, 3, 3, 5, 5, 1, 5, 1, 4, 3, 1, 2, 0, 5, 1,\n",
      "        1, 2, 1, 2, 0, 2, 0, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 0, 1, 5, 5, 5, 1, 5, 0, 3, 5, 3, 2, 2, 2, 4, 1, 4, 5, 0, 2, 4, 2, 4,\n",
      "        0, 5, 2, 2, 5, 1, 4, 4, 2, 1, 3, 3, 5, 5, 5, 0, 2, 3, 4, 4, 0, 1, 3, 1,\n",
      "        4, 4, 3, 0, 3, 4, 3, 4, 5, 3, 5, 4, 4, 2, 0, 3, 4, 5, 5, 0, 0, 5, 0, 2,\n",
      "        3, 2, 4, 0, 1, 5, 0, 0, 2, 4, 4, 5, 3, 5, 1, 1, 3, 0, 4, 4, 2, 1, 5, 3,\n",
      "        2, 2, 5, 0, 2, 0, 5, 1, 4, 1, 5, 4, 1, 3, 1, 4, 4, 3, 5, 5, 0, 1, 5, 1,\n",
      "        3, 5, 1, 4, 4, 1, 5, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 3, 0, 4, 1, 1, 5, 1, 4, 0, 0, 4, 3, 3, 3, 4, 5, 4, 1, 0, 5, 0, 1, 4,\n",
      "        0, 5, 4, 3, 1, 4, 1, 2, 5, 2, 3, 3, 3, 1, 5, 5, 4, 5, 0, 5, 0, 2, 5, 5,\n",
      "        0, 5, 4, 0, 3, 5, 4, 4, 1, 0, 2, 4, 3, 0, 5, 4, 4, 4, 3, 5, 2, 5, 3, 1,\n",
      "        0, 3, 4, 0, 5, 4, 2, 5, 0, 3, 0, 2, 1, 2, 5, 3, 5, 4, 3, 1, 4, 3, 5, 4,\n",
      "        4, 0, 4, 0, 3, 4, 5, 4, 1, 5, 3, 2, 0, 3, 3, 1, 5, 0, 2, 2, 4, 5, 4, 2,\n",
      "        4, 0, 0, 2, 3, 0, 0, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 1, 5, 2, 4, 5, 2, 3, 2, 1, 5, 3, 4, 0, 1, 1, 5, 1, 0, 5, 4, 4, 4, 4,\n",
      "        0, 2, 5, 1, 2, 3, 4, 1, 1, 4, 2, 0, 2, 3, 5, 1, 2, 4, 4, 5, 5, 1, 5, 0,\n",
      "        1, 3, 3, 0, 4, 4, 1, 0, 5, 5, 0, 3, 0, 4, 4, 5, 3, 3, 0, 1, 1, 0, 4, 5,\n",
      "        0, 1, 0, 0, 4, 2, 5, 2, 2, 0, 4, 3, 3, 0, 1, 3, 3, 0, 4, 4, 3, 1, 2, 4,\n",
      "        4, 3, 0, 4, 4, 1, 2, 5, 2, 1, 0, 3, 1, 4, 1, 1, 5, 1, 2, 3, 5, 3, 4, 4,\n",
      "        5, 5, 4, 1, 1, 4, 3, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 0, 4, 1, 1, 3, 5, 1, 0, 1, 0, 1, 4, 3, 3, 2, 4, 3, 3, 5, 4, 5, 3, 5,\n",
      "        4, 4, 4, 2, 5, 1, 3, 4, 5, 0, 3, 5, 3, 4, 3, 1, 0, 3, 5, 3, 1, 3, 0, 0,\n",
      "        0, 3, 5, 1, 3, 0, 4, 2, 3, 1, 3, 5, 2, 5, 0, 0, 0, 5, 3, 1, 1, 3, 4, 0,\n",
      "        2, 2, 0, 3, 0, 0, 4, 0, 3, 4, 5, 3, 2, 0, 5, 0, 4, 5, 0, 4, 2, 2, 1, 2,\n",
      "        1, 3, 1, 3, 2, 0, 0, 1, 3, 3, 1, 3, 5, 5, 0, 5, 1, 0, 4, 5, 3, 1, 3, 5,\n",
      "        2, 0, 4, 3, 5, 5, 0, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 1, 4, 2, 5, 4, 0, 2, 5, 5, 5, 0, 4, 0, 5, 4, 5, 5, 1, 2, 5, 0, 2, 2,\n",
      "        1, 5, 0, 4, 3, 0, 2, 4, 4, 1, 5, 5, 2, 1, 2, 0, 1, 3, 3, 1, 0, 3, 3, 0,\n",
      "        3, 2, 5, 5, 3, 0, 0, 5, 2, 0, 5, 2, 4, 4, 5, 5, 4, 1, 0, 0, 5, 2, 4, 4,\n",
      "        0, 0, 4, 3, 1, 4, 2, 2, 4, 1, 0, 5, 0, 5, 4, 5, 2, 3, 1, 4, 0, 0, 3, 5,\n",
      "        0, 1, 4, 2, 4, 1, 4, 0, 3, 2, 4, 5, 2, 2, 1, 4, 4, 1, 1, 4, 4, 1, 4, 0,\n",
      "        4, 1, 4, 4, 5, 4, 0, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 3, 4, 4, 3, 0, 4, 0, 4, 2, 0, 2, 1, 5, 5, 3, 2, 0, 0, 2, 3, 4, 3, 1,\n",
      "        3, 0, 3, 4, 5, 3, 0, 0, 2, 1, 2, 1, 4, 4, 5, 3, 0, 0, 0, 3, 1, 0, 1, 4,\n",
      "        4, 3, 5, 3, 2, 2, 5, 2, 1, 2, 1, 0, 4, 4, 3, 5, 1, 2, 4, 1, 5, 0, 4, 4,\n",
      "        4, 5, 5, 0, 3, 4, 2, 3, 3, 4, 0, 1, 5, 5, 3, 0, 5, 5, 0, 1, 4, 0, 0, 2,\n",
      "        1, 2, 4, 1, 5, 2, 4, 5, 4, 4, 5, 5, 1, 5, 5, 3, 1, 5, 4, 0, 5, 3, 1, 3,\n",
      "        4, 5, 3, 3, 5, 4, 4, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 4, 3, 3, 4, 3, 5, 1, 1, 5, 4, 0, 5, 5, 4, 5, 1, 4, 0, 1, 5, 2, 2, 0,\n",
      "        4, 3, 1, 0, 3, 1, 4, 2, 3, 1, 0, 5, 5, 3, 2, 4, 3, 2, 2, 0, 5, 2, 4, 0,\n",
      "        3, 1, 2, 3, 5, 5, 5, 4, 4, 3, 3, 4, 4, 0, 2, 0, 5, 5, 1, 4, 4, 0, 3, 1,\n",
      "        3, 3, 4, 3, 4, 4, 1, 0, 3, 5, 4, 2, 0, 1, 3, 5, 0, 4, 0, 5, 5, 4, 4, 3,\n",
      "        5, 1, 4, 3, 0, 3, 1, 5, 3, 4, 4, 1, 5, 0, 4, 2, 3, 5, 1, 2, 2, 4, 0, 2,\n",
      "        3, 4, 0, 0, 3, 3, 0, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 0, 5, 3, 2, 5, 2, 2, 0, 4, 0, 4, 3, 1, 3, 1, 5, 4, 5, 1, 4, 0, 1, 1,\n",
      "        5, 5, 1, 0, 4, 3, 5, 5, 2, 1, 1, 1, 3, 4, 1, 4, 3, 0, 3, 1, 0, 5, 5, 4,\n",
      "        5, 0, 2, 2, 4, 4, 2, 3, 4, 3, 3, 4, 1, 1, 1, 3, 3, 1, 0, 4, 0, 5, 4, 4,\n",
      "        4, 1, 2, 2, 3, 3, 4, 3, 3, 5, 2, 0, 0, 5, 3, 3, 1, 1, 3, 0, 0, 0, 0, 5,\n",
      "        5, 3, 4, 1, 4, 3, 4, 0, 3, 5, 2, 2, 3, 3, 5, 2, 5, 3, 2, 2, 4, 4, 2, 5,\n",
      "        4, 2, 1, 0, 1, 5, 4, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 5, 5, 3, 0, 0, 4, 4, 5, 1, 4, 0, 3, 0, 4, 2, 5, 0, 0, 0, 5, 5, 5, 4,\n",
      "        4, 4, 1, 4, 5, 5, 5, 0, 3, 1, 0, 5, 5, 1, 5, 1, 5, 0, 3, 1, 0, 2, 5, 2,\n",
      "        0, 0, 3, 2, 0, 4, 2, 5, 1, 4, 4, 0, 1, 5, 2, 0, 2, 5, 4, 2, 4, 2, 1, 0,\n",
      "        3, 0, 1, 4, 1, 5, 0, 4, 4, 3, 4, 4, 2, 1, 3, 4, 2, 5, 4, 1, 5, 5, 1, 5,\n",
      "        2, 5, 5, 0, 0, 4, 3, 5, 5, 0, 4, 5, 1, 3, 1, 1, 5, 3, 4, 5, 2, 3, 2, 0,\n",
      "        0, 0, 3, 0, 1, 3, 0, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 1, 2, 5, 4, 2, 0, 2, 3, 4, 5, 2, 3, 0, 2, 1, 2, 0, 0, 2, 0, 1, 5, 5,\n",
      "        5, 4, 5, 2, 4, 1, 2, 0, 2, 5, 5, 5, 0, 1, 0, 3, 0, 4, 1, 4, 1, 2, 3, 3,\n",
      "        2, 3, 2, 4, 3, 5, 0, 3, 1, 4, 5, 1, 0, 4, 4, 0, 1, 2, 0, 2, 5, 3, 2, 4,\n",
      "        3, 5, 1, 4, 3, 0, 2, 2, 4, 3, 2, 1, 1, 3, 5, 5, 3, 2, 5, 2, 2, 3, 3, 4,\n",
      "        5, 3, 2, 2, 5, 5, 4, 4, 5, 2, 5, 1, 5, 4, 2, 0, 4, 0, 1, 5, 5, 4, 0, 5,\n",
      "        5, 1, 5, 0, 1, 5, 2, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 5, 1, 0, 3, 2, 0, 3, 1, 0, 2, 2, 5, 1, 3, 1, 4, 5, 2, 2, 1, 4, 5, 2,\n",
      "        1, 0, 5, 3, 5, 1, 3, 4, 4, 2, 2, 3, 1, 3, 4, 2, 5, 1, 0, 1, 0, 5, 4, 3,\n",
      "        0, 3, 5, 4, 5, 5, 1, 1, 5, 2, 2, 3, 0, 4, 0, 4, 4, 3, 3, 0, 1, 5, 4, 5,\n",
      "        4, 5, 4, 5, 5, 3, 3, 3, 3, 3, 0, 5, 3, 4, 3, 2, 3, 5, 5, 3, 2, 3, 0, 3,\n",
      "        4, 3, 3, 5, 1, 5, 0, 5, 0, 1, 2, 2, 1, 2, 2, 1, 5, 2, 5, 4, 0, 0, 0, 2,\n",
      "        1, 5, 0, 3, 5, 5, 5, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 2, 3, 3, 5, 2, 3, 2, 4, 5, 1, 4, 0, 1, 1, 3, 1, 4, 3, 0, 5, 4, 4, 3,\n",
      "        5, 3, 0, 0, 3, 1, 3, 3, 4, 4, 2, 1, 5, 2, 5, 3, 1, 3, 2, 2, 0, 3, 5, 4,\n",
      "        3, 5, 3, 2, 0, 0, 4, 2, 2, 1, 2, 2, 4, 5, 5, 1, 3, 0, 5, 5, 5, 1, 4, 5,\n",
      "        1, 1, 3, 5, 4, 4, 3, 3, 0, 1, 3, 4, 3, 4, 5, 2, 4, 4, 3, 5, 1, 1, 2, 1,\n",
      "        5, 1, 3, 2, 5, 1, 3, 3, 5, 3, 5, 3, 3, 3, 4, 3, 4, 2, 5, 5, 0, 1, 1, 1,\n",
      "        1, 3, 2, 4, 2, 0, 0, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 2, 5, 3, 5, 5, 3, 3, 4, 2, 0, 3, 4, 4, 1, 4, 5, 3, 4, 4, 2, 0, 5, 4,\n",
      "        0, 3, 0, 1, 1, 0, 2, 5, 2, 3, 5, 5, 3, 1, 3, 4, 3, 5, 5, 1, 3, 3, 2, 2,\n",
      "        4, 1, 0, 3, 0, 2, 4, 5, 2, 1, 0, 3, 4, 3, 2, 3, 2, 5, 2, 4, 3, 5, 0, 3,\n",
      "        3, 1, 2, 4, 0, 5, 1, 4, 1, 5, 4, 5, 3, 5, 4, 5, 5, 0, 3, 2, 0, 1, 0, 4,\n",
      "        4, 4, 4, 1, 2, 2, 0, 2, 0, 1, 5, 2, 4, 0, 2, 5, 4, 0, 1, 5, 2, 0, 3, 2,\n",
      "        3, 2, 4, 0, 5, 2, 4, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 1, 1, 5, 0, 4, 0, 4, 4, 0, 5, 5, 2, 0, 2, 1, 3, 5, 2, 1, 4, 5, 1, 2,\n",
      "        5, 0, 2, 0, 3, 3, 5, 4, 1, 0, 2, 0, 3, 5, 5, 0, 4, 3, 0, 5, 4, 2, 5, 4,\n",
      "        4, 5, 3, 3, 0, 3, 2, 4, 5, 2, 3, 5, 2, 4, 0, 3, 3, 5, 1, 3, 1, 4, 0, 3,\n",
      "        1, 1, 5, 1, 0, 1, 3, 0, 3, 3, 3, 0, 3, 3, 1, 3, 4, 0, 3, 2, 2, 5, 3, 0,\n",
      "        4, 4, 3, 3, 0, 0, 4, 2, 1, 4, 3, 0, 0, 0, 0, 5, 0, 3, 5, 4, 1, 5, 1, 1,\n",
      "        5, 0, 2, 3, 4, 0, 1, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([3, 4, 0, 3, 1, 5, 4, 1, 5, 1, 0, 4, 1, 2, 0, 0, 0, 5, 2, 1, 2, 1, 4, 4,\n",
      "        0, 1, 5, 0, 4, 0, 0, 4, 3, 0, 4, 4, 3, 4, 0, 5, 0, 0, 1, 4, 3, 4, 5, 1,\n",
      "        2, 1, 2, 2, 2, 3, 3, 0, 1, 2, 3, 1, 4, 3, 3, 1, 3, 1, 1, 5, 5, 4, 5, 4,\n",
      "        5, 3, 5, 0, 0, 1, 1, 4, 2, 2, 4, 3, 5, 1, 0, 4, 3, 3, 2, 3, 1, 2, 5, 3,\n",
      "        5, 2, 5, 0, 0, 5, 4, 5, 5, 1, 0, 5, 5, 4, 4, 5, 1, 3, 4, 4, 1, 4, 3, 1,\n",
      "        2, 4, 1, 0, 0, 5, 5, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 0, 3, 0, 1, 1, 5, 3, 5, 4, 0, 0, 2, 0, 3, 3, 4, 0, 4, 5, 0, 1, 1, 2,\n",
      "        2, 0, 5, 4, 0, 3, 4, 4, 2, 0, 2, 5, 3, 4, 0, 1, 4, 1, 5, 0, 4, 4, 1, 4,\n",
      "        5, 1, 1, 2, 3, 0, 1, 3, 0, 0, 0, 1, 4, 5, 5, 4, 3, 0, 0, 5, 2, 5, 3, 4,\n",
      "        2, 2, 3, 4, 5, 4, 2, 0, 3, 4, 2, 2, 4, 1, 2, 3, 4, 3, 5, 4, 5, 1, 5, 5,\n",
      "        0, 2, 1, 1, 5, 4, 4, 0, 4, 0, 5, 0, 3, 2, 0, 5, 1, 5, 0, 1, 3, 4, 5, 3,\n",
      "        2, 4, 1, 1, 2, 0, 5, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([2, 4, 4, 5, 1, 3, 0, 3, 3, 0, 5, 0, 1, 3, 2, 2, 2, 2, 3, 4, 3, 1, 4, 4,\n",
      "        1, 4, 0, 0, 5, 5, 1, 0, 3, 3, 0, 4, 0, 2, 0, 2, 4, 3, 3, 3, 5, 0, 1, 5,\n",
      "        0, 0, 4, 4, 2, 0, 0, 0, 3, 3, 1, 2, 4, 3, 0, 5, 2, 0, 3, 1, 3, 4, 2, 0,\n",
      "        2, 1, 0, 3, 4, 5, 0, 1, 4, 5, 1, 2, 3, 3, 4, 4, 4, 2, 1, 3, 5, 4, 0, 5,\n",
      "        3, 3, 1, 1, 1, 1, 1, 2, 4, 4, 4, 1, 0, 1, 5, 3, 5, 5, 3, 5, 4, 4, 3, 3,\n",
      "        0, 0, 0, 5, 1, 3, 5, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 3, 5, 2, 0, 0, 4, 5, 0, 5, 5, 3, 2, 5, 5, 4, 5, 0, 3, 5, 5, 0, 2, 4,\n",
      "        4, 5, 0, 1, 4, 1, 4, 2, 0, 3, 4, 0, 5, 0, 3, 2, 2, 0, 2, 0, 4, 2, 2, 0,\n",
      "        4, 4, 1, 3, 4, 1, 0, 1, 5, 3, 5, 5, 4, 3, 0, 4, 5, 1, 5, 3, 1, 5, 1, 1,\n",
      "        3, 4, 1, 2, 5, 5, 1, 5, 0, 0, 1, 1, 3, 0, 1, 1, 4, 3, 5, 4, 2, 4, 2, 5,\n",
      "        0, 0, 0, 0, 1, 4, 1, 0, 1, 4, 4, 0, 2, 0, 5, 5, 4, 1, 3, 5, 0, 3, 1, 3,\n",
      "        3, 4, 1, 5, 1, 3, 3, 4])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 4, 0, 4, 4, 4, 0, 4, 5, 4, 2, 2, 0, 2, 3, 2, 5, 4, 0, 4, 5, 3, 5, 5,\n",
      "        4, 2, 1, 5, 0, 5, 3, 3, 4, 3, 5, 3, 1, 5, 1, 2, 3, 5, 3, 5, 2, 3, 4, 5,\n",
      "        4, 4, 3, 4, 0, 5, 5, 2, 2, 1, 3, 3, 1, 4, 3, 5, 0, 1, 4, 3, 3, 0, 0, 5,\n",
      "        0, 2, 1, 5, 0, 3, 5, 4, 0, 5, 5, 3, 0, 1, 5, 4, 2, 4, 0, 1, 3, 0, 3, 1,\n",
      "        2, 4, 4, 5, 3, 2, 3, 5, 0, 1, 0, 3, 3, 4, 0, 1, 0, 5, 3, 4, 0, 5, 1, 5,\n",
      "        2, 0, 5, 1, 4, 3, 2, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 3, 4, 0, 4, 2, 3, 0, 3, 0, 4, 3, 5, 0, 5, 4, 2, 2, 4, 2, 1, 0, 4, 0,\n",
      "        4, 3, 3, 4, 1, 4, 0, 5, 0, 3, 1, 2, 3, 3, 2, 1, 4, 2, 0, 0, 3, 4, 4, 3,\n",
      "        0, 2, 4, 5, 4, 1, 5, 3, 2, 1, 1, 0, 1, 5, 3, 1, 4, 5, 2, 3, 2, 5, 3, 4,\n",
      "        3, 4, 3, 4, 4, 3, 5, 2, 5, 5, 4, 4, 1, 2, 4, 4, 2, 0, 1, 5, 1, 2, 2, 1,\n",
      "        1, 0, 2, 1, 2, 5, 1, 4, 0, 4, 5, 4, 1, 3, 5, 4, 0, 4, 4, 2, 0, 3, 3, 3,\n",
      "        0, 3, 1, 5, 0, 0, 0, 1])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([0, 3, 4, 2, 0, 1, 4, 2, 3, 2, 0, 4, 5, 5, 5, 5, 4, 4, 4, 4, 5, 4, 1, 1,\n",
      "        0, 3, 3, 1, 1, 5, 5, 1, 0, 5, 1, 3, 0, 5, 1, 1, 2, 2, 3, 2, 0, 2, 0, 3,\n",
      "        0, 5, 1, 4, 0, 1, 2, 3, 0, 0, 1, 4, 5, 4, 3, 2, 4, 4, 4, 3, 0, 1, 4, 3,\n",
      "        0, 1, 5, 5, 2, 1, 3, 2, 0, 0, 4, 5, 2, 4, 4, 2, 0, 0, 3, 4, 4, 5, 1, 5,\n",
      "        2, 5, 2, 4, 1, 3, 1, 5, 4, 4, 5, 0, 5, 1, 5, 2, 3, 4, 3, 2, 1, 3, 3, 3,\n",
      "        4, 2, 2, 5, 5, 2, 4, 5])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([4, 4, 5, 3, 0, 0, 1, 5, 0, 3, 3, 1, 3, 1, 3, 2, 2, 5, 5, 3, 1, 4, 4, 3,\n",
      "        3, 1, 5, 3, 1, 1, 2, 4, 0, 0, 0, 0, 5, 2, 3, 4, 5, 5, 0, 2, 1, 4, 0, 1,\n",
      "        3, 4, 2, 4, 5, 0, 5, 0, 3, 5, 0, 4, 5, 5, 3, 4, 2, 4, 5, 0, 5, 5, 3, 4,\n",
      "        0, 2, 0, 4, 4, 0, 3, 3, 2, 4, 3, 4, 3, 2, 0, 1, 2, 5, 1, 4, 0, 3, 0, 5,\n",
      "        2, 2, 0, 3, 5, 4, 0, 2, 3, 1, 3, 1, 5, 3, 3, 1, 2, 2, 5, 0, 1, 4, 5, 1,\n",
      "        4, 3, 5, 4, 5, 3, 2, 2])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n",
      "torch.Size([128]) tensor([5, 5, 4, 4, 2, 2, 3, 0, 3, 5, 5, 5, 3, 1, 5, 2, 0, 1, 4, 2, 2, 5, 5, 0,\n",
      "        4, 3, 5, 0, 3, 3, 1, 3, 3, 3, 3, 1, 2, 3, 1, 3, 4, 3, 4, 2, 3, 4, 0, 4,\n",
      "        1, 5, 0, 0, 3, 1, 4, 2, 0, 0, 3, 3, 0, 2, 4, 5, 2, 3, 4, 3, 5, 4, 2, 1,\n",
      "        2, 5, 4, 5, 0, 4, 5, 4, 3, 3, 0, 5, 4, 5, 0, 3, 3, 2, 4, 4, 4, 3, 4, 4,\n",
      "        4, 5, 1, 1, 0, 3, 3, 3, 5, 4, 2, 2, 4, 1, 3, 5, 5, 0, 3, 1, 0, 4, 2, 5,\n",
      "        3, 4, 5, 1, 0, 0, 5, 3])\n",
      "conv1 torch.Size([128, 12, 64, 4])\n",
      "conv2 torch.Size([128, 32, 32, 2])\n",
      "conv3 torch.Size([128, 64, 32, 2])\n",
      "output torch.Size([128, 6])\n"
     ]
    },
    {
     "ename": "RuntimeError",
     "evalue": "1D target tensor expected, multi-target not supported",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mRuntimeError\u001B[0m                              Traceback (most recent call last)",
      "\u001B[1;32m~\\AppData\\Local\\Temp/ipykernel_5272/1884612169.py\u001B[0m in \u001B[0;36m<module>\u001B[1;34m\u001B[0m\n\u001B[0;32m      6\u001B[0m \u001B[0mcriterion\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mnn\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mCrossEntropyLoss\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;33m)\u001B[0m                       \u001B[1;31m#使用交叉熵作为损失函数\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m      7\u001B[0m \u001B[1;31m# 使用训练集的20%作为验证\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m----> 8\u001B[1;33m \u001B[0mnet\u001B[0m\u001B[1;33m,\u001B[0m\u001B[0mtrain_process\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mtrain_model\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mnet\u001B[0m\u001B[1;33m,\u001B[0m\u001B[0mtrain_loader\u001B[0m\u001B[1;33m,\u001B[0m\u001B[1;36m0.8\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mcriterion\u001B[0m\u001B[1;33m,\u001B[0m\u001B[0moptimizer\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mnum_epochs\u001B[0m\u001B[1;33m=\u001B[0m\u001B[1;36m25\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m      9\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;32m~\\AppData\\Local\\Temp/ipykernel_5272/3671221822.py\u001B[0m in \u001B[0;36mtrain_model\u001B[1;34m(model, traindataloader, train_rate, criterion, optimizer, num_epochs)\u001B[0m\n\u001B[0;32m     45\u001B[0m                 \u001B[0moutput\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mmodel\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mb_x\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m     46\u001B[0m                 \u001B[0mpre_lab\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mtorch\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0margmax\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0moutput\u001B[0m\u001B[1;33m,\u001B[0m\u001B[1;36m1\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m---> 47\u001B[1;33m                 \u001B[0mloss\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mcriterion\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0moutput\u001B[0m\u001B[1;33m,\u001B[0m\u001B[0mb_y\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m     48\u001B[0m                 \u001B[0mval_loss\u001B[0m \u001B[1;33m+=\u001B[0m \u001B[0mloss\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mitem\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;33m)\u001B[0m \u001B[1;33m*\u001B[0m \u001B[0mb_x\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0msize\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;36m0\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m     49\u001B[0m                 \u001B[0mval_corrects\u001B[0m \u001B[1;33m+=\u001B[0m \u001B[0mtorch\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0msum\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mpre_lab\u001B[0m \u001B[1;33m==\u001B[0m \u001B[0mb_y\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mdata\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;32mc:\\users\\dengxixi\\miniconda3\\envs\\torch-ocr\\lib\\site-packages\\torch\\nn\\modules\\module.py\u001B[0m in \u001B[0;36m_call_impl\u001B[1;34m(self, *input, **kwargs)\u001B[0m\n\u001B[0;32m   1049\u001B[0m         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks\n\u001B[0;32m   1050\u001B[0m                 or _global_forward_hooks or _global_forward_pre_hooks):\n\u001B[1;32m-> 1051\u001B[1;33m             \u001B[1;32mreturn\u001B[0m \u001B[0mforward_call\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;33m*\u001B[0m\u001B[0minput\u001B[0m\u001B[1;33m,\u001B[0m \u001B[1;33m**\u001B[0m\u001B[0mkwargs\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m   1052\u001B[0m         \u001B[1;31m# Do not call functions when jit is used\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m   1053\u001B[0m         \u001B[0mfull_backward_hooks\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mnon_full_backward_hooks\u001B[0m \u001B[1;33m=\u001B[0m \u001B[1;33m[\u001B[0m\u001B[1;33m]\u001B[0m\u001B[1;33m,\u001B[0m \u001B[1;33m[\u001B[0m\u001B[1;33m]\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;32mc:\\users\\dengxixi\\miniconda3\\envs\\torch-ocr\\lib\\site-packages\\torch\\nn\\modules\\loss.py\u001B[0m in \u001B[0;36mforward\u001B[1;34m(self, input, target)\u001B[0m\n\u001B[0;32m   1118\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m   1119\u001B[0m     \u001B[1;32mdef\u001B[0m \u001B[0mforward\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mself\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0minput\u001B[0m\u001B[1;33m:\u001B[0m \u001B[0mTensor\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mtarget\u001B[0m\u001B[1;33m:\u001B[0m \u001B[0mTensor\u001B[0m\u001B[1;33m)\u001B[0m \u001B[1;33m->\u001B[0m \u001B[0mTensor\u001B[0m\u001B[1;33m:\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m-> 1120\u001B[1;33m         return F.cross_entropy(input, target, weight=self.weight,\n\u001B[0m\u001B[0;32m   1121\u001B[0m                                ignore_index=self.ignore_index, reduction=self.reduction)\n\u001B[0;32m   1122\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;32mc:\\users\\dengxixi\\miniconda3\\envs\\torch-ocr\\lib\\site-packages\\torch\\nn\\functional.py\u001B[0m in \u001B[0;36mcross_entropy\u001B[1;34m(input, target, weight, size_average, ignore_index, reduce, reduction)\u001B[0m\n\u001B[0;32m   2822\u001B[0m     \u001B[1;32mif\u001B[0m \u001B[0msize_average\u001B[0m \u001B[1;32mis\u001B[0m \u001B[1;32mnot\u001B[0m \u001B[1;32mNone\u001B[0m \u001B[1;32mor\u001B[0m \u001B[0mreduce\u001B[0m \u001B[1;32mis\u001B[0m \u001B[1;32mnot\u001B[0m \u001B[1;32mNone\u001B[0m\u001B[1;33m:\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m   2823\u001B[0m         \u001B[0mreduction\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0m_Reduction\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mlegacy_get_string\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0msize_average\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mreduce\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m-> 2824\u001B[1;33m     \u001B[1;32mreturn\u001B[0m \u001B[0mtorch\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0m_C\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0m_nn\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mcross_entropy_loss\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0minput\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mtarget\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mweight\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0m_Reduction\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mget_enum\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mreduction\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m,\u001B[0m \u001B[0mignore_index\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m   2825\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m   2826\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;31mRuntimeError\u001B[0m: 1D target tensor expected, multi-target not supported"
     ]
    }
   ],
   "source": [
    "#输出网络结构\n",
    "net = Net()     #创建实例\n",
    "print(net)\n",
    "#对模型进行训练\n",
    "optimizer = Adam(net.parameters(),lr=0.0003)            #优化器\n",
    "criterion = nn.CrossEntropyLoss()                       #使用交叉熵作为损失函数\n",
    "# 使用训练集的20%作为验证\n",
    "net,train_process = train_model(net,train_loader,0.8, criterion,optimizer, num_epochs=25)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "#可视化模型训练过程中\n",
    "plt.figure(figsize=(12,4))\n",
    "plt.subplot(1,2,1)\n",
    "plt.plot(train_process.epoch,train_process.train_loss_all,\"ro-\",label=\"Train loss\")\n",
    "plt.plot(train_process.epoch,train_process.val_loss_all,\"bs-\",label=\"Val loss\")\n",
    "plt.legend()\n",
    "plt.xlabel(\"epoch\")\n",
    "plt.ylabel(\"Loss\")\n",
    "plt.subplot(1,2,2)\n",
    "plt.plot(train_process.epoch,train_process.train_acc_all,\"ro-\",label=\"Train acc\")\n",
    "plt.plot(train_process.epoch,train_process.val_acc_all,\"bs-\",label=\"Val acc\")\n",
    "plt.xlabel(\"epoch\")\n",
    "plt.ylabel(\"acc\")\n",
    "plt.legend()\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "#对测试集进行预测,计算模型的泛化能力\n",
    "def test(model,testdataloader,criterion):\n",
    "    test_loss_all = []\n",
    "    test_acc_all = []\n",
    "    test_loss = 0.0\n",
    "    test_corrects = 0\n",
    "    test_num = 0\n",
    "    for step,(input,target) in enumerate(testdataloader):   #取标签和样本\n",
    "        target = target.long()\n",
    "        #target = torch.Tensor(target).long()\n",
    "        model.eval()                                       #设置模型为训练模式，对Droopou有用\n",
    "        output = model(input)\n",
    "        # print(b_x)#取得模型预测结果\n",
    "        pre_lab = torch.argmax(output,1)                    #横向获得最大值位置\n",
    "        loss = criterion(output,target)                     #每个样本的loss\n",
    "        test_loss += loss.item() * input.size(0)            #此处的b_x.size(0)=batch_size。此处相当于一个batch的loss？计算的是整体训练的loss\n",
    "        #print(pre_lab)\n",
    "        #print(input.data)\n",
    "        test_corrects += torch.sum(pre_lab == target.data)  #测试正确个数\n",
    "        test_num += input.size(0)\n",
    "    test_loss_all.append(test_loss / test_num)\n",
    "    test_acc_all.append(test_corrects.double().item() / test_num)\n",
    "    print('Test all Loss: {:.4f} Test Acc: {:.4f}'.format(test_loss_all[-1], test_acc_all[-1]))\n",
    "\n",
    "test = test(net,test_loader,criterion)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}